package com.hanson.controller;

import com.hanson.common.bean.ResultMessage;
import com.hanson.entity.ApplyCashOutBean;
import com.hanson.entity.ApplyInfoBean;
import com.hanson.service.ApplyCashOutService;
import com.hanson.service.ApplyInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/web/applyInfo")
public class WebApplyInfoController {
    @Autowired
    private ApplyInfoService applyInfoService;
    @Autowired
    private ApplyCashOutService applyCashOutService;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ResultMessage add(@RequestBody ApplyInfoBean applyInfoBean, @CookieValue("openId") String openId) throws Exception {
        ResultMessage resultMessage = new ResultMessage();
        resultMessage.setData(applyInfoService.addApplyInfo(openId, applyInfoBean));
        resultMessage.setMsg("提交申请成功！");
        return resultMessage;
    }

    @RequestMapping(value = "/addCashOut", method = RequestMethod.POST)
    public ResultMessage addCashOut(@RequestBody ApplyCashOutBean applyCashOutBean, @CookieValue("openId") String openId) throws Exception {
        ResultMessage resultMessage = new ResultMessage();
        applyCashOutService.add(applyCashOutBean, openId);
        resultMessage.setMsg("提交申请成功！");
        return resultMessage;
    }
}
